package com.zaizai.zaizai_good.controller;

import java.util.List;

import com.zaizai.zaizai_good.domain.R;
import com.zaizai.zaizai_good.utils.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zaizai.zaizai_good.domain.pojo.Goodstype;
import com.zaizai.zaizai_good.service.IGoodstypeService;

/**
 * 商品类别Controller
 * 
 * @author lql
 * @date 2024-10-04
 */
@RestController
@RequestMapping("/goodStype")
public class GoodstypeController extends BaseController
{
    @Autowired
    private IGoodstypeService goodstypeService;

    /**
     * 查询商品类别列表
     */
    @GetMapping("/list")
    public TableDataInfo list(Goodstype goodstype)
    {
        startPage();
        List<Goodstype> list = goodstypeService.selectGoodstypeList(goodstype);
        return getDataTable(list);
    }

    /**
     * 获取商品类别详细信息
     */
    @GetMapping(value = "/{id}")
    public R<Goodstype> getInfo(@PathVariable("id") Long id)
    {
        return R.ok(goodstypeService.selectGoodstypeById(id));
    }

    /**
     * 新增商品类别
     */
    @PostMapping
    public R<Integer> add(@RequestBody Goodstype goodstype)
    {
        return R.ok(goodstypeService.insertGoodstype(goodstype));
    }

    /**
     * 修改商品类别
     */
    @PutMapping
    public R<Integer> edit(@RequestBody Goodstype goodstype)
    {
        return R.ok(goodstypeService.updateGoodstype(goodstype));
    }

    /**
     * 删除商品类别
     */

	@DeleteMapping("/{ids}")
    public R<Integer> remove(@PathVariable Long[] ids)
    {
        return R.ok(goodstypeService.deleteGoodstypeByIds(ids));
    }
}
